package day9;

import java.util.Scanner;

/**
 * @author oldliu
 * @since 1.0
 */
public class CarTest {
    public static void main(String[] args) {
        RentalCompany c = new RentalCompany();
        Scanner sc = new Scanner(System.in);
        int ch = 0;
        while (true) {
            System.out.println("1.查看车辆情况；2.租车；3.还车；4.报废；5.采购新车；6.查看租车记录；7：报废；0：退出");
            ch = sc.nextInt();
            if (ch == 1) {
                c.showInfor();
            } else if (ch == 2) {
                System.out.print(">>>>租什么类型的车（客车/轿车）：");
                String rentType = sc.next();
                c.show(rentType);//
                System.out.print("想租的车牌号：");
                String chepai = sc.next();

                Vechile car = c.rent(rentType, chepai);
                if (car == null) {
                    System.out.println("没租成功");
                    continue;
                }
                System.out.print("天数:");
                int days = sc.nextInt();
                double qian = car.calcMoney(days);
                System.out.println("请输入姓名和手机号：");
                String cname = sc.next();
                String shouji = sc.next();
                c.addHis(car.getLicensePlate(), cname, shouji, days);
                System.out.println("请支付人民币" + qian + "元");
            } else if (ch == 3) {
                System.out.print("要还的车牌号：");
                String chepai = sc.next();
                boolean f = c.rtnBack(chepai);
                System.out.println(f ? "成功" : "失败！@");
            } else if (ch == 4) {

            } else if (ch == 5) {
                System.out.println("买轿车还是客车：");
                String type = sc.next();
                if (type.equals("轿车")) {
                    Car newA = new Car();
                    System.out.println("请输入新车品牌：");
                    newA.setBrand(sc.next());
                    System.out.println("请输入新车车牌：");
                    newA.setLicensePlate(sc.next());
                    System.out.println("请输入新车型号：");
                    newA.setType(sc.next());
                    System.out.println("请输入新车日租金：");
                    newA.setDailyRent(sc.nextDouble());
                    c.buy(newA);
                } else {
                    BigCar newA = new BigCar();
                    System.out.println("请输入新车品牌：");
                    newA.setBrand(sc.next());
                    System.out.println("请输入新车车牌：");
                    newA.setLicensePlate(sc.next());
                    System.out.println("请输入座位数：");
                    newA.setSeats(sc.nextInt());
                    System.out.println("请输入新车日租金：");
                    newA.setDailyRent(sc.nextDouble());
                    c.buy(newA);
                }
            } else if (ch == 6) {
                c.showHis();
            } else if (ch ==7) {
                System.out.print("请输入要报废的车的车牌号：");
                String chpai=sc.next();
                Vechile b = c.scrapCar(chpai);
                //if b!=null b.show()获得报废的车辆信息
                System.out.println(b!=null?"报废成功":"没有找到车辆或者处于出租状态！");
            }else if (ch == 0) {
                break;
            }
        }
    }
}
